{{define "content"}}
<div class="page-title-box">
    <div class="row align-items-center">
        <div class="col-auto">
            <h2 class="page-title">编辑</h2>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-12">
        <form id="group" class="card" method="post">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-2">
                            <label class="form-label">名称</label>
                            <input name="name" type="text" class="form-control" placeholder="请输入名称" value="{{.Group.Name}}" required>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="mb-2">
                            <label class="form-label">启用</label>
                            <label class="form-check form-switch">
                                <input name="status" class="form-check-input" type="checkbox" {{if eq .Group.Status 1}}checked{{end}}>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="card-footer text-right">
                <input name="id" type="hidden" value="{{.Group.ID}}">
                <button type="submit" class="btn btn-primary">提交</button>
                <a href="/group/list" class="btn btn-danger ml-2">返回</a>
            </div>
        </form>
    </div>
</div>
{{end}}
{{define "script"}}
<script type="text/javascript">
    $(document).ready(function () {
        $("#group").on("submit", function (event) {
            $('#group').ajaxSubmit({
                url: "/group/update",
                dataType: "json",
                timeout: 60000,
                success: function (data) {
                    if (data.code == 200) {
                        window.location.href = "/group/list";
                    } else {
                        alert(data.message);
                    }
                }
            })
            return false;
        });
    });
</script>
{{end}}